//********************************************************************************************
//
// File : arp.h implement for Address Resolution Protocol
//
//********************************************************************************************
//
// Copyright (C) 2007
//
// This program is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free Software
// Foundation; either version 2 of the License, or (at your option) any later
// version.
// This program is distributed in the hope that it will be useful, but
//
// WITHOUT ANY WARRANTY;
//
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with
// this program; if not, write to the Free Software Foundation, Inc., 51
// Franklin St, Fifth Floor, Boston, MA 02110, USA
//
// http://www.gnu.de/gpl-ger.html
//
//********************************************************************************************
#ifndef __ARP_h__
#define __ARP_h__

#include "BasicTypes.h"

class cArp
{
//*******************************************************************************
//constance
public:
    static const U8  ARP_PACKET_LEN         = 28;

    static const U16 ARP_OPCODE_REQUEST_V   = 0x0001;
    static const U8  ARP_OPCODE_REQUEST_H_V = 0x00;
    static const U8  ARP_OPCODE_REQUEST_L_V = 0x01;
    static const U16 ARP_OPCODE_REPLY_V     = 0x0002;
    static const U8  ARP_OPCODE_REPLY_H_V   = 0x00;
    static const U8  ARP_OPCODE_REPLY_L_V   = 0x02;
    static const U8  ARP_HARDWARE_TYPE_H_V  = 0x00;
    static const U8  ARP_HARDWARE_TYPE_L_V  = 0x01;
    static const U8  ARP_PROTOCOL_H_V       = 0x08;
    static const U8  ARP_PROTOCOL_L_V       = 0x00;
    static const U8  ARP_HARDWARE_SIZE_V    = 0x06;
    static const U8  ARP_PROTOCOL_SIZE_V    = 0x04;
    static const U8  ARP_HARDWARE_TYPE_H_P  = 0x0E;
    static const U8  ARP_HARDWARE_TYPE_L_P  = 0x0F;
    static const U8  ARP_PROTOCOL_H_P       = 0x10;
    static const U8  ARP_PROTOCOL_L_P       = 0x11;
    static const U8  ARP_HARDWARE_SIZE_P    = 0x12;
    static const U8  ARP_PROTOCOL_SIZE_P    = 0x13;
    static const U8  ARP_OPCODE_H_P         = 0x14;
    static const U8  ARP_OPCODE_L_P         = 0x15;
    static const U8  ARP_SRC_MAC_P          = 0x16;
    static const U8  ARP_SRC_IP_P           = 0x1C;
    static const U8  ARP_DST_MAC_P          = 0x20;
    static const U8  ARP_DST_IP_P           = 0x26;

//*******************************************************************************
//functions
public:
    static void GenerateArpPacket ( U8 *pBuff, U8 *pDestMac, U8 *pDestIP );
    //static void arp_send_request ( U8 *pBuff, U8 *dest_ip );
    static void SendReply ( U8 *pBuff, U8 *pDestMac );
    static bool IsArpPacket ( U8 *pBuff, U16 iOpcode );
    //static U8 arp_who_is ( U8 *pBuff, U8 *pDestMac, U8 *dest_ip );
};

#endif

